#include<bits/stdc++.h>
using namespace std;
#define int long long
#define llg long long
#define sig signed
#define rg register
#define sht short
#define endl "\n"
int t,n,m,cnt,V,d[100005],v[100005],a[100005],p[100005],fast[100005],ans,to[100005];
signed main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--){
        memset(fast,0,sizeof(fast));
        cin>>n>>m>>V>>V;
        rg int i;
        for(i=1;i<=n;i++)cin>>d[i]>>v[i]>>a[i];
        for(i=1;i<=m;i++)cin>>p[i];
        p[m+1]=1e15;
        sort(p+1,p+1+m);
        for(i=1;i<=n;i++){
            if(a[i]>=0){
                if(d[i]>p[m])continue;
                int speed=v[i]*v[i]+2*a[i]*(p[m]-d[i]);
                if(speed>V*V){
                    fast[i]=1;
                    ans++;
                }
            }else{
                if(d[i]>p[m])continue;
                int x=lower_bound(p+1,p+1+m,d[i])-p;
                to[i]=x;
                if(v[i]*v[i]+2*a[i]*(p[x]-d[i])<0)continue;
                int speed=v[i]*v[i]+2*a[i]*(p[x]-d[i]);
                if(speed>V*V){
                    fast[i]=1;
                    ans++;
                }
            }
        }
        cout<<ans<<" ";
        if(ans==0){
            cout<<"0\n";
            return 0;
        }
        int x=0,y=m+1;
        for(i=1;i<=n;i++){
            if(!fast[i])continue;
            if(a[i]==0)continue;
            if(a[i]>=0){
                double ds=max(0ll,(v[i]*v[i]-V*V))/2.0/a[i];
                int dis=ds+1-1e-10;
                int tmp=lower_bound(p+1,p+1+m,dis)-p;
                x=max(x,tmp);
            }else{
                double ds=v[i]*v[i]/2.0/a[i];
                int dis=ds;
                int tmp=lower_bound(p+1,p+1+m,dis)-p;
                y=min(y,tmp);
            }
        }
        if(x<=y)cout<<n-1;
        else cout<<n-3;
        cout<<endl;
    }
    return 0;
}
